/*! \file block_header.h
 *	\brief <write description for block_header.h>
 *
 *	created:	2009/11/20
 *	created:	20:11:2009   18:24
 *	filename: 	o:\main\libs\mem\impl\block_header.h
 *	file path:	o:\main\libs\mem\impl
 *	file base:	block_header
 *	file ext:	h
 *	author:		Vitalii Trubchaninov
 *				venngraydog@gmail.com
 */

#ifndef _MEM_BLOCK_HEADER_H_
#define _MEM_BLOCK_HEADER_H_

#pragma once

#include "../defs.h"

#if TT_MEM_ENABLED && TT_MEM_PROFILING

namespace tt{
namespace mem{
namespace impl{

enum BlockType{
	BT_UNKNOWN,
	BT_ONE,
	BT_ARRAY,
};

class BlockInfo;

struct BlockHeader
{
	std::size_t	size;
	BlockType	block_type;
	BlockInfo*	section;

	BlockHeader()
	: size(0)
	, block_type(BT_UNKNOWN)
	, section(NULL)
	{
	}
};
const std::size_t BLOCK_HEADER_SIZE = sizeof(BlockHeader);

BlockHeader* to_block_header(void* mem);
void* to_memory(BlockHeader* block);

template<BlockType block_type>
BlockHeader* block_new( std::size_t size);

template<BlockType block_type>
void block_delete(BlockHeader* block);

} //impl
} //mem
} //namespace tt

#include "block_header.inl"

#endif //TT_MEM_ENABLED && TT_MEM_PROFILING

#endif //_MEM_BLOCK_HEADER_H_
